package cn.change360.newappchildrenenglish.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.change360.newappchildrenenglish.R;

/**
 * Created by Jacky on 2015/11/12.
 */

public class WidgetDictation extends LinearLayout {

    TextView word_text;

    public WidgetDictation(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public WidgetDictation(Context context) {
        super(context);
        initView(context);
    }

    private void initView(Context context) {
        LayoutInflater.from(context).inflate(R.layout.widget_dictation, this);
        word_text = (TextView) findViewById(R.id.word_text);
    }

    private void init(Context context, AttributeSet attrs) {
        initView(context);

        final TypedArray typedArray = getContext().obtainStyledAttributes(
                attrs, R.styleable.WidgetLetter);
        String text = typedArray.getString(R.styleable.WidgetLetter_letter_text);
        if (text != null) {
            word_text.setText(text);
        }
        typedArray.recycle();
    }

    public void setText(String t) {
        word_text.setText(t.toLowerCase() + "");
    }

    public String getText() {
        return word_text.getText() + "";
    }
}